/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: Faculty of informatics, Burapha University 01
 * License Type: Purchased
 */
package cn.imvc.app.entities;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="commission")
public class Commission implements Serializable {
	public Commission() {
	}
	
	private int id;
	
	private cn.imvc.app.entities.Member member;
	
	private cn.imvc.app.entities.Account account;
	
	private Byte type;
	
	private Integer referId;
	
	private String referCode;
	
	private Integer money;
	
	private Integer rate;
	
	private java.util.Date createdAt;
	
	private cn.imvc.app.entities.Member fromMember;
	
	public void setId(int value) {
		this.id = value;
	}
	
	@Column(name="id", nullable=false)	
	@Id	
	@GeneratedValue(generator="CN_IMVC_APP_ENTITIES_COMMISSION_ID_GENERATOR")	
	@org.hibernate.annotations.GenericGenerator(name="CN_IMVC_APP_ENTITIES_COMMISSION_ID_GENERATOR", strategy="identity")	
	public int getId() {
		return id;
	}
	
	@Transient	
	public int getORMID() {
		return getId();
	}
	
	/**
	 * 分佣类型1订单 2加盟 3升级
	 */
	public void setType(byte value) {
		setType(new Byte(value));
	}
	
	/**
	 * 分佣类型1订单 2加盟 3升级
	 */
	public void setType(Byte value) {
		this.type = value;
	}
	
	/**
	 * 分佣类型1订单 2加盟 3升级
	 */
	@Column(name="type", nullable=true)	
	public Byte getType() {
		return type;
	}
	
	/**
	 * 订单编码
	 */
	public void setReferCode(String value) {
		this.referCode = value;
	}
	
	/**
	 * 订单编码
	 */
	@Column(name="referCode", nullable=true, length=255)	
	public String getReferCode() {
		return referCode;
	}
	
	/**
	 * 分佣金额
	 */
	public void setMoney(int value) {
		setMoney(new Integer(value));
	}
	
	/**
	 * 分佣金额
	 */
	public void setMoney(Integer value) {
		this.money = value;
	}
	
	/**
	 * 分佣金额
	 */
	@Column(name="money", nullable=true, length=10)	
	public Integer getMoney() {
		return money;
	}
	
	/**
	 * 分佣比例
	 */
	public void setRate(int value) {
		setRate(new Integer(value));
	}
	
	/**
	 * 分佣比例
	 */
	public void setRate(Integer value) {
		this.rate = value;
	}
	
	/**
	 * 分佣比例
	 */
	@Column(name="rate", nullable=true, length=10)	
	public Integer getRate() {
		return rate;
	}
	
	public void setCreatedAt(java.util.Date value) {
		this.createdAt = value;
	}
	
	@Column(name="createdAt", nullable=true)	
	@Temporal(TemporalType.TIMESTAMP)	
	public java.util.Date getCreatedAt() {
		return createdAt;
	}
	
	/**
	 * 订单id
	 */
	public void setReferId(int value) {
		setReferId(new Integer(value));
	}
	
	/**
	 * 订单id
	 */
	public void setReferId(Integer value) {
		this.referId = value;
	}
	
	/**
	 * 订单id
	 */
	@Column(name="referId", nullable=true, length=10)	
	public Integer getReferId() {
		return referId;
	}
	
	public void setMember(cn.imvc.app.entities.Member value) {
		this.member = value;
	}
	
	@ManyToOne(targetEntity=cn.imvc.app.entities.Member.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="memberId", referencedColumnName="id", nullable=false) })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public cn.imvc.app.entities.Member getMember() {
		return member;
	}
	
	public void setAccount(cn.imvc.app.entities.Account value) {
		this.account = value;
	}
	
	@ManyToOne(targetEntity=cn.imvc.app.entities.Account.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="accountId", referencedColumnName="id", nullable=false) })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public cn.imvc.app.entities.Account getAccount() {
		return account;
	}
	
	public void setFromMember(cn.imvc.app.entities.Member value) {
		this.fromMember = value;
	}
	
	@ManyToOne(targetEntity=cn.imvc.app.entities.Member.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="fromMemberId", referencedColumnName="id") })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public cn.imvc.app.entities.Member getFromMember() {
		return fromMember;
	}
	
	public String toString() {
		return toString(false);
	}
	
	public String toString(boolean idOnly) {
		if (idOnly) {
			return String.valueOf(getId());
		}
		else {
			StringBuffer sb = new StringBuffer();
			sb.append("Commission[ ");
			sb.append("Id=").append(getId()).append(" ");
			if (getMember() != null)
				sb.append("Member.Persist_ID=").append(getMember().toString(true)).append(" ");
			else
				sb.append("Member=null ");
			if (getAccount() != null)
				sb.append("Account.Persist_ID=").append(getAccount().toString(true)).append(" ");
			else
				sb.append("Account=null ");
			sb.append("Type=").append(getType()).append(" ");
			sb.append("ReferId=").append(getReferId()).append(" ");
			sb.append("ReferCode=").append(getReferCode()).append(" ");
			sb.append("Money=").append(getMoney()).append(" ");
			sb.append("Rate=").append(getRate()).append(" ");
			sb.append("CreatedAt=").append(getCreatedAt()).append(" ");
			if (getFromMember() != null)
				sb.append("FromMember.Persist_ID=").append(getFromMember().toString(true)).append(" ");
			else
				sb.append("FromMember=null ");
			sb.append("]");
			return sb.toString();
		}
	}
	
}
